﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="dbTestFixture">
    <xs:complexType>
      <xs:all>
        <xs:element name="usage" type="xs:string" minOccurs="0"/>
        <xs:element name="globalSetting" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="dbConnection" maxOccurs="1">
                <xs:complexType>
                  <xs:attribute name="connectionName" type="xs:string" use="required"/>
                  <xs:attribute name="connectionString" type="xs:string" use="required"/>
                  <xs:attribute name="providerName" type="xs:string" use="required"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
            <xs:attribute name="exportRecordCount" type="xs:unsignedByte" use="optional"/>
            <xs:attribute name="wrapStringByCDATA" type="xs:boolean" use="optional"/>
          </xs:complexType>
          
          <!--<xs:unique name="abc">
            <xs:selector xpath="./dbConnection"/>
            <xs:field xpath="@connectionName"/>
          </xs:unique>-->
          
        </xs:element>

        <xs:element name="procDeclarations" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="procDeclaration" maxOccurs="unbounded" minOccurs="0">
                <xs:complexType>
                  <xs:all>
                    <xs:element name="arguments" maxOccurs="1" minOccurs="0">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element  name="argument" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:attribute name="name" type="xs:string" use="required"/>
                              <xs:attribute name="direction" type="ArgumentDirectionType" use="required"/>
                              <xs:attribute name="type" type="ArgumentDataType" use="required"/>
                              <xs:attribute name="size" type="xs:unsignedByte" use="optional"/>
                              <xs:attribute name="value" type="xs:string" use="optional"/>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="remark" type="xs:string" minOccurs="0" maxOccurs="1"/>
                  </xs:all>
                  <xs:attribute name="alias" type="xs:string" use="required"/>
                  <xs:attribute name="name" type="xs:string" use="required"/>
                  <xs:attribute name="dbConnection" type="xs:string" use="required"/>
                  <xs:attribute name="namespace" type="xs:string" use="optional"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="sqlDeclarations" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element  name="sqlDeclaration"  maxOccurs="unbounded" minOccurs="0">
                <xs:complexType>
                  <xs:all>
                    <xs:element name="sql" type="xs:string"  maxOccurs="1"  />
                    <xs:element name="arguments" minOccurs="0" maxOccurs="1">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="argument" maxOccurs="unbounded" minOccurs="0" >
                            <xs:complexType>
                              <xs:attribute name="name" type="xs:string" use="required"/>
                              <xs:attribute name="direction" type="ArgumentDirectionType" use="required"/>
                              <xs:attribute name="type" type="ArgumentDataType" use="required"/>
                              <xs:attribute name="size" type="xs:unsignedByte" use="optional"/>
                              <xs:attribute name="value" type="xs:string" use="optional"/>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="remark" type="xs:string" minOccurs="0"/>
                  </xs:all>
                  <xs:attribute name="alias" type="xs:string" use="required"/>
                  <xs:attribute name="dbConnection" type="xs:string" use="required"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="perfTestCases" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="perfTestCase" maxOccurs="unbounded"  minOccurs="0">
                <xs:complexType>
                  <xs:all>
                    <xs:element name="testCaseRemark" type="xs:string" minOccurs="0"/>
                    <xs:element name="inputArguments" minOccurs="0" maxOccurs="1">
                      <xs:complexType>
                        <xs:sequence>
                          <xs:element name="argument" minOccurs="0" maxOccurs="unbounded">
                            <xs:complexType>
                              <xs:attribute name="name" type="xs:string" use="required"/>
                              <xs:attribute name="value" type="xs:string" use="required"/>
                            </xs:complexType>
                          </xs:element>
                        </xs:sequence>
                      </xs:complexType>
                    </xs:element>
                  </xs:all>
                  <xs:attribute name="testCaseName" type="xs:string" use="required"/>
                  <xs:attribute name="statementAlias" type="xs:string" use="required"/>
                  <xs:attribute name="ignoreThis" type="xs:boolean" use="optional"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>

        <xs:element name="unitTestCases" minOccurs="0" maxOccurs="1">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="unitTestCase" maxOccurs="unbounded" minOccurs="0" >
                <xs:complexType>
                  <xs:all>
                    <xs:element name="testCaseRemark" type="xs:string" minOccurs="0" maxOccurs="1"/>
                    <xs:element name="targetResultset"  maxOccurs="1">
                      <xs:complexType>
                        <xs:all>
                          <xs:element name="inputArguments" minOccurs="0" maxOccurs="1">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="argument" minOccurs="0" maxOccurs="unbounded" >
                                  <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required"/>
                                    <xs:attribute name="value" type="xs:unsignedByte" use="required"/>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="outputSetting" minOccurs="0" maxOccurs="1">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element  name="field" maxOccurs="unbounded" minOccurs="0" >
                                  <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required"/>
                                    <xs:attribute name="outputName" type="xs:string" use="required"/>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:all>
                        <xs:attribute name="statementAlias" type="xs:string" use="required"/>
                        <xs:attribute name="outputArgument" type="xs:string" use="required"/>
                      </xs:complexType>
                    </xs:element>
                    <xs:element name="referenceResultset"  maxOccurs="1">
                      <xs:complexType>
                        <xs:all>
                          <xs:element name="inputArguments" minOccurs="0" maxOccurs="1">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element name="argument" maxOccurs="unbounded" minOccurs="0" >
                                  <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required"/>
                                    <xs:attribute name="value" type="xs:unsignedByte" use="required"/>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                          <xs:element name="outputSetting" minOccurs="0" maxOccurs="1">
                            <xs:complexType>
                              <xs:sequence>
                                <xs:element  name="field" maxOccurs="unbounded" minOccurs="0">
                                  <xs:complexType>
                                    <xs:attribute name="name" type="xs:string" use="required"/>
                                    <xs:attribute name="outputName" type="xs:string" use="required"/>
                                  </xs:complexType>
                                </xs:element>
                              </xs:sequence>
                            </xs:complexType>
                          </xs:element>
                        </xs:all>
                        <xs:attribute name="statementAlias" type="xs:string" use="required"/>
                        <xs:attribute name="outputArgument" type="xs:string" use="required"/>
                      </xs:complexType>
                    </xs:element>
                  </xs:all>
                  <xs:attribute name="testCaseName" type="xs:string" use="required"/>
                  <xs:attribute name="assertion" type="assertionType" use="required"/>
                  <xs:attribute name="ignoreThis" type="xs:boolean" use="optional"/>
                </xs:complexType>
              </xs:element>
            </xs:sequence>
          </xs:complexType>
        </xs:element>
      </xs:all>
    </xs:complexType>
  </xs:element>



  <xs:simpleType name="assertionType">
    <xs:annotation>
      <xs:documentation>assertion type for unit test</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="StrictEqual"/>
      <xs:enumeration value="SetEqual"/>
      <xs:enumeration value="IsSupersetOf"/>
      <xs:enumeration value="IsProperSupersetOf"/>
      <xs:enumeration value="IsSubsetOf"/>
      <xs:enumeration value="IsProperSubsetOf"/>
      <xs:enumeration value="Overlaps"/>
      <xs:enumeration value="RecordCountEqual"/>
      
      <xs:enumeration value="!StrictEqual"/>
      <xs:enumeration value="!SetEqual"/>
      <xs:enumeration value="!IsSupersetOf"/>
      <xs:enumeration value="!IsProperSupersetOf"/>
      <xs:enumeration value="!IsSubsetOf"/>
      <xs:enumeration value="!IsProperSubsetOf"/>
      <xs:enumeration value="!Overlaps"/>
      <xs:enumeration value="!RecordCountEqual"/>
    </xs:restriction>
  </xs:simpleType>

 

  <xs:simpleType name="ArgumentDirectionType">
    <xs:annotation>
      <xs:documentation>direction type of procedure argument</xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      <xs:enumeration value="Input"/>
      <xs:enumeration value="InputOutput"/>
      <xs:enumeration value="Output"/>
      <xs:enumeration value="Return"/>
      <xs:enumeration value="AnonymousOutput"/>
      
    </xs:restriction>
  </xs:simpleType>
 
  <xs:simpleType name="ArgumentDataType">
    <xs:annotation>
      <xs:documentation>Date type of procedure argument </xs:documentation>
    </xs:annotation>
    <xs:restriction base="xs:string">
      
      <!--Oracle data type-->
      <xs:enumeration value="ORA_CHAR"/>
      <xs:enumeration value="ORA_VARCHAR"/>
      <xs:enumeration value="ORA_VARCHAR2"/>
      <xs:enumeration value="ORA_NCHAR"/>
      <xs:enumeration value="ORA_NVARCHAR"/>
      <xs:enumeration value="ORA_NVARCHAR2"/>
      <xs:enumeration value="ORA_NUMBER"/>
      <xs:enumeration value="ORA_DATETIME"/>
      <xs:enumeration value="ORA_TIMESTAMP"/>
      <xs:enumeration value="ORA_TIMESTAMPLOCAL"/>
      <xs:enumeration value="ORA_TIMESTAMPWITHTZ"/>
      <xs:enumeration value="ORA_INTERVALDAYTOSECOND"/>
      <xs:enumeration value="ORA_INTERVALYEARTOMONTH"/>
      <xs:enumeration value="ORA_BYTE"/>
      <xs:enumeration value="ORA_INT"/>
      <xs:enumeration value="ORA_CURSOR"/>
      <xs:enumeration value="ORA_FLOAT"/>
      <xs:enumeration value="ORA_REAL"/>
      <xs:enumeration value="ORA_DOUBLE"/>
      <xs:enumeration value="ORA_ROWID"/>
      
      

      <!--MS SQL server data type-->
      <xs:enumeration value="MSSQL_BIGINT"/>
      <xs:enumeration value="MSSQL_BIT"/>
      <xs:enumeration value="MSSQL_CHAR"/>
      <xs:enumeration value="MSSQL_DATETIME"/>
      <xs:enumeration value="MSSQL_DECIMAL"/>
      <xs:enumeration value="MSSQL_NUMERIC"/>
      <xs:enumeration value="MSSQL_FLOAT"/>
      <xs:enumeration value="MSSQL_INT"/>
      <xs:enumeration value="MSSQL_MONEY"/>
      <xs:enumeration value="MSSQL_NCHAR"/>
      <xs:enumeration value="MSSQL_NTEXT"/>
      <xs:enumeration value="MSSQL_NVARCHAR"/>
      <xs:enumeration value="MSSQL_REAL"/>
      <xs:enumeration value="MSSQL_GUID"/>
      <xs:enumeration value="MSSQL_SMALLDATETIME"/>
      <xs:enumeration value="MSSQL_SMALLINT"/>
      <xs:enumeration value="MSSQL_SMALLMONEY"/>
      <xs:enumeration value="MSSQL_TEXT"/>
      <xs:enumeration value="MSSQL_TIMESTAMP"/>
      <xs:enumeration value="MSSQL_TINYINT"/>
      <xs:enumeration value="MSSQL_VARCHAR"/>
      <xs:enumeration value="MSSQL_RECORDSET"/>

      
      <!--Excel data type--> 
      <xs:enumeration value="XLS_CHAR"/>
      <xs:enumeration value="XLS_NCHAR"/>
      <xs:enumeration value="XLS_DATE"/>
      <xs:enumeration value="XLS_DATETIME"/>
      <xs:enumeration value="XLS_CURRENCY"/>
      <xs:enumeration value="XLS_DOUBLE"/>
      <xs:enumeration value="XLS_INT"/>
      <xs:enumeration value="XLS_RECORDSET"/>

    </xs:restriction>
  </xs:simpleType>

</xs:schema>
